package com.foreveredu.propms.web.struts.action;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


import com.foreveredu.propms.domain.District;
import com.foreveredu.propms.domain.PageModel;
import com.foreveredu.propms.domain.SubDistrict;
import com.foreveredu.propms.service.IManagementService;
import com.foreveredu.propms.service.IPropQueryService;
import com.foreveredu.propms.web.struts.actionform.PropQueryActionForm;
import com.foreveredu.propms.web.util.ExportExcelUtils;

/**
 * 处理物业收费查询请求
 * 
 * @author hushigang
 * 
 */
public class PropQueryAction extends AbstractBaseDispatchAction {

	private IManagementService managementService = null;
	private IPropQueryService propQueryService = null;

	// 获得日志记录器
	Logger log = Logger.getLogger(AccountAction.class);

	public IManagementService getManagementService() {
		return managementService;
	}

	public void setManagementService(IManagementService managementService) {
		this.managementService = managementService;
	}

	public void setPropQueryService(IPropQueryService propQueryService) {
		this.propQueryService = propQueryService;
	}

	public IPropQueryService getPropQueryService() {
		return propQueryService;
	}
	
	// 跳转到小区月收缴率查询条件页面
	public ActionForward querySubMonthlyPaidRate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

		//获得所有的物业服务处
		List<District> distList = managementService.findDistricts();
		request.setAttribute("distList", distList);
		
		return mapping.findForward("query_subMonthlyPaidRate");
	}

	//执行小区月收缴率查询操作
	public ActionForward doQuerySubMonthlyPaidRate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

		//获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm)form;
		int distId = pqform.getDistId();
		int subId = pqform.getSubId();
		int year = pqform.getYear();
		int month = pqform.getMonth();
		
		List<Map<String, Object>> queryList = new ArrayList<Map<String,Object>>();
		
		//当管理员不选择物业服务处，则查询所有小区当月物业费收缴率
		if (distId == 0) {
			//获得所有的小区
			List<SubDistrict> subList = managementService.findSubDistricts();
			for(SubDistrict sub:subList) {
				queryList.add(propQueryService.querySubPaidRate(sub, year, month));
			}
		} else {
			Map<String, Object> queryMap = propQueryService.querySubPaidRate(managementService.findSubDistrictById(subId), year, month);
			queryList.add(queryMap);
		}
		request.setAttribute("queryList", queryList);
		request.setAttribute("year", year);
		request.setAttribute("month", month);
		
		return mapping.findForward("doQuery_subMonthlyPaidRate");
	}

	// 跳转到小区收费月汇总查询条件页面
	public ActionForward querySubMonthlyCharge(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

		//获得所有的物业服务处
		List<District> distList = managementService.findDistricts();
		request.setAttribute("distList", distList);
		
		return mapping.findForward("query_subMonthlyCharge");
	}

	//执行小区收费月汇总查询操作
	public ActionForward doQuerySubMonthlyCharge(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

		//获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm)form;
		int distId = pqform.getDistId();
		int subId = pqform.getSubId();
		int year = pqform.getYear();
		int month = pqform.getMonth();
		
		List<Map<String, Object>> queryList = new ArrayList<Map<String,Object>>();
		
		//当管理员不选择物业服务处，则查询所有小区当月物业费收缴率
		if (distId == 0) {
			//获得所有的小区
			List<SubDistrict> subList = managementService.findSubDistricts();
			for(SubDistrict sub:subList) {
				queryList.add(propQueryService.querySubMonthlyCharge(sub, year, month));
			}
		} else {
			Map<String, Object> queryMap = propQueryService.querySubMonthlyCharge(managementService.findSubDistrictById(subId), year, month);
			queryList.add(queryMap);
		}
		log.info("queryList.size()="+queryList.size());
		request.setAttribute("queryList", queryList);
		request.setAttribute("year", year);
		request.setAttribute("month", month);
		
		return mapping.findForward("doQuery_subMonthlyCharge");
	}
	
	// 跳转到小区收费年总查询条件页面
	public ActionForward querySubMonthlyChargeYear(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

		//获得所有的物业服务处
		List<District> distList = managementService.findDistricts();
		request.setAttribute("distList", distList);
		
		return mapping.findForward("query_subMonthlyChargeYear");
	}
	
	//小区年收费查询
	public ActionForward doQuerySubMonthlyChargeYear(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

		//获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm)form;
		int distId = pqform.getDistId();
		int subId = pqform.getSubId();
		int year = pqform.getYear();
		
		List<Map<String, Object>> queryList = new ArrayList<Map<String,Object>>();
		
		//当管理员不选择物业服务处，则查询所有小区当月物业费收缴率
		if (distId == 0) {
			//获得所有的小区
			List<SubDistrict> subList = managementService.findSubDistricts();
			for(SubDistrict sub:subList) {
				queryList.add(propQueryService.querySubMonthlyChargeYear(sub, year));
			}
		} else {
			Map<String, Object> queryMap = propQueryService.querySubMonthlyChargeYear(managementService.findSubDistrictById(subId), year);
			queryList.add(queryMap);
		}
		log.info("queryList.size()="+queryList.size());
		request.setAttribute("queryList", queryList);
		request.setAttribute("year", year);
		
		return mapping.findForward("doQuery_subMonthlyChargeYear");
	}
	
	
	//业主缴费汇总表
	/**
	 * 业主缴费汇总表
	 */
	// 跳转到小区收费月汇总查询条件页面
	public ActionForward queryOwnerMonthlyCharge(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

		//获得所有的物业服务处
		List<District> distList = managementService.findDistricts();
		request.setAttribute("distList", distList);
		
		return mapping.findForward("queryOwnerMonthlyCharge");
	}
	/**
	 * 业主缴费汇总表
	 */
	//执行小区收费月汇总查询操作
	public ActionForward doQueryOwnerMonthlyCharge(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

		PageModel pm = new PageModel();
		//获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm)form;
		int distId = pqform.getDistId();
		int subId = pqform.getSubId();//小区id
		int year = pqform.getYear();
		int month = pqform.getMonth();
		
		List<Map<String, Object>> queryList = new ArrayList<Map<String,Object>>();
		
		//当管理员不选择物业服务处，则查询所有小区当月物业费收缴率
		if (distId == 0) {
			//获得所有的小区
			subId=0;//把小区id设置为o，并且查询所有的小区的所有的用户
			SubDistrict sub=new SubDistrict();
			sub.setId(subId);//获得页面传入的小区Id
		 pm=propQueryService.queryUserBySub(sub, year, month,0);
		} else {
			SubDistrict sub=new SubDistrict();
			sub.setId(subId);//获得页面传入的小区Id
		 pm=propQueryService.queryUserBySub(sub, year, month,0);
		}
		//只需要调用一次
		log.info("queryList.size()="+queryList.size());
		request.setAttribute("pm", pm);
		request.setAttribute("year", year);
		request.setAttribute("month", month);
		request.setAttribute("subId", subId);
		request.setAttribute("distId", distId);
		
		
		/*
		 * 小区的用户
		 */
		return mapping.findForward("doQueryOwnerMonthlyCharge");
	}

	public ActionForward queryOwnerCharge(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

		//获得所有的物业服务处
		List<District> distList = managementService.findDistricts();
		request.setAttribute("distList", distList);
		
		return mapping.findForward("queryOwnerCharge");
	}

	/**
	 * 业主缴费明细表
	 */
	public ActionForward doQueryOwnerCharge(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		PageModel pm = new PageModel();
		//获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm)form;
		int distId = pqform.getDistId();
		int subId = pqform.getSubId();//小区id
		int year = pqform.getYear();
		int month = pqform.getMonth();
		
		List<Map<String, Object>> queryList = new ArrayList<Map<String,Object>>();
		
		//当管理员不选择物业服务处，则查询所有小区当月物业费收缴率
		if (distId == 0) {
			//获得所有的小区
			subId=0;//把小区id设置为o，并且查询所有的小区的所有的用户
			SubDistrict sub=new SubDistrict();
			sub.setId(subId);//获得页面传入的小区Id
		 pm=propQueryService.queryUserBySub(sub, year, month,0);
		} else {
			SubDistrict sub=new SubDistrict();
			sub.setId(subId);//获得页面传入的小区Id
		 pm=propQueryService.queryUserBySub(sub, year, month,0);
		}
		//只需要调用一次
		log.info("queryList.size()="+queryList.size());
		request.setAttribute("pm", pm);
		request.setAttribute("year", year);
		request.setAttribute("month", month);
		request.setAttribute("subId", subId);
		request.setAttribute("distId", distId);
		
		
		
		/*
		 * 小区的用户
		 */
		return mapping.findForward("doQueryOwnerCharge");
	}
	
	
	/**
	 * 业主缴费明细表
	 */
	public ActionForward doQueryOwnerChargeToExcel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		//获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm)form;
		int distId = pqform.getDistId();
		int subId = pqform.getSubId();//小区id
		int year = pqform.getYear();
		int month = pqform.getMonth();
		int pageType=pqform.getPageType();
		List<Map<String, Object>> queryList = new ArrayList<Map<String,Object>>();
		
		//当管理员不选择物业服务处，则查询所有小区当月物业费收缴率
		if (distId == 0) {
			//获得所有的小区
			subId=0;//把小区id设置为o，并且查询所有的小区的所有的用户
			SubDistrict sub=new SubDistrict();
			sub.setId(subId);//获得页面传入的小区Id
			queryList=propQueryService.doQueryownerChargeToExcel(sub, year, month);
		} else {
			SubDistrict sub=new SubDistrict();
			sub.setId(subId);//获得页面传入的小区Id
			queryList=propQueryService.doQueryownerChargeToExcel(sub, year, month);
		}
		//只需要调用一次
		if(pageType==0){
			//小区户主明细缴费
			try{
				response.setContentType("octets/stream"); 
				//设置表名
				String fileName="业主缴费明细表("+year+"年"+month+"月)";
				response.addHeader("Content-Disposition","attachment;filename="+new String(fileName.getBytes("GBK"),"ISO8859-1")+".xls"); 
				
	            OutputStream out = response.getOutputStream();
	            //设置表格中的字段名
	            String[] headers = {"业主", "应缴金额", "实收金额","物业服务费","单独物业服务费","电费","水费","停车服务费","垃圾清运费","路灯电费","二次提水费","单独电费","单独水费","单独垃圾清运费","单独路灯电费","单独二次提水电费"};
	            //设置Key，然后通过这个Key去Map数组中取值

			
	            String[] columns ={"ownerName","paidSum","propCharge","powerCharge","waterCharge","carCharge","rubbishCharge","lightCharge","water2ndCharge","totalSum","charge1","charge2","charge3","charge4","charge5","charge6"};
	            ExportExcelUtils.exportExcel("业主缴费明细表", headers, columns, queryList, out, "");
	            out.close();
			}catch (Exception e) {
				e.printStackTrace();
			}
		}else{
			//小区户主汇总缴费
			try{
				response.setContentType("octets/stream"); 
				//设置表名
				String fileName="业主缴费汇总表("+year+"年"+month+"月)";
				response.addHeader("Content-Disposition","attachment;filename="+new String(fileName.getBytes("GBK"),"ISO8859-1")+".xls"); 
				
	            OutputStream out = response.getOutputStream();
	            //设置表格中的字段名
	            String[] headers = {"业主", "应缴金额", "实收金额"};
	            //设置Key，然后通过这个Key去Map数组中取值

			
	            String[] columns ={"ownerName","paidSum","propCharge"};
	            ExportExcelUtils.exportExcel("业主缴费汇总表", headers, columns, queryList, out, "");
	            out.close();
			}catch (Exception e) {
				e.printStackTrace();
			}
		}
		System.out.println(pageType+"穿入的类型");
	
		
		/*
		 * 小区的用户
		 */
		return null;
	}

	/*
	 * 用来分页的方法
	 * (non-Javadoc)
	 * @see org.apache.struts.actions.DispatchAction#unspecified(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	public ActionForward unspecified(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		PropQueryActionForm pqform = (PropQueryActionForm)form;
		int distId = pqform.getDistId();
		int subId = pqform.getSubId();//小区id
		int year = pqform.getYear();
		int month = pqform.getMonth();
		int pageType=pqform.getPageType();
		SubDistrict sub=new SubDistrict();
		
		sub.setId(subId);//获得页面传入的小区Id
		int offset = 0;
		String pageOffset = request.getParameter("pager.offset");// 获得翻页参数，即下一开始的纪录位置
		if (pageOffset != null && !pageOffset.equals("")) {
			offset = Integer.parseInt(pageOffset);
		}
		if (offset < 0) {
			if(pageType==0){
				return mapping.findForward("doQueryOwnerCharge");//明细表
			}else{
				return mapping.findForward("doQueryOwnerMonthlyCharge");//汇总
			}
			
		}
		PageModel pm = new PageModel();
		pm=propQueryService.queryUserBySub(sub, year, month,offset);
		request.setAttribute("pm", pm);
		request.setAttribute("year", year);
		request.setAttribute("month", month);
		request.setAttribute("subId", subId);
		request.setAttribute("distId", distId);
		if(pageType==0){
			return mapping.findForward("doQueryOwnerCharge");//明细表
		}else{
			return mapping.findForward("doQueryOwnerMonthlyCharge");//汇总
		}
	}
	

	/**
	 * 公司收费查询
	 */
	// 跳转到公司收费月汇总查询条件页面
	public ActionForward queryCompanyMonthlyCharge(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		// 获得所有的物业服务处
		List<District> distList = managementService.findDistricts();
		request.setAttribute("distList", distList);

		return mapping.findForward("query_CompanyMonthlyCharge");
	}

	// 执行公司收费月汇总查询操作
	public ActionForward doqueryCompanyMonthlyCharge(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		// 获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm) form;
		int year = pqform.getYear();
		int month = pqform.getMonth();

		List<Map<String, Object>> queryList = new ArrayList<Map<String, Object>>();
		// 获得所有的小区
		List<SubDistrict> subList = managementService.findSubDistricts();
		for (SubDistrict sub : subList) {
			queryList.add(propQueryService.querySubMonthlyCharge(sub, year,
					month));
		}
		//统计总数
		float totalSumRet = 0;
		float paidSumRet = 0;
		float propChargeRet = 0;
		float powerChargeRet = 0;
		float waterChargeRet = 0;
		float carChargeRet = 0;
		float rubbishChargeRet = 0;
		float lightChargeRet = 0;
		float water2ndChargeRet = 0;
		for (int i = 0; i < queryList.size(); i++) {
			totalSumRet += Float.parseFloat(queryList.get(i).get("totalSum")
					.toString());
			paidSumRet += Float.parseFloat(queryList.get(i).get("paidSum")
					.toString());
			propChargeRet += Float.parseFloat(queryList.get(i).get("propCharge")
					.toString());
			powerChargeRet += Float.parseFloat(queryList.get(i).get("powerCharge")
					.toString());
			waterChargeRet += Float.parseFloat(queryList.get(i).get("waterCharge")
					.toString());
			carChargeRet += Float.parseFloat(queryList.get(i).get("carCharge")
					.toString());
			rubbishChargeRet += Float.parseFloat(queryList.get(i).get("rubbishCharge")
					.toString());
			lightChargeRet += Float.parseFloat(queryList.get(i).get("lightCharge")
					.toString());
			water2ndChargeRet += Float.parseFloat(queryList.get(i).get("water2ndCharge")
					.toString());
		}
		log.info("queryList.size()=" + queryList.size());
		request.setAttribute("queryList", queryList);
		request.setAttribute("year", year);
		request.setAttribute("month", month);
		request.setAttribute("totalSumRet", totalSumRet);
		request.setAttribute("paidSumRet", paidSumRet);
		request.setAttribute("propChargeRet", propChargeRet);
		request.setAttribute("powerChargeRet", powerChargeRet);
		request.setAttribute("waterChargeRet", waterChargeRet);
		request.setAttribute("carChargeRet", carChargeRet);
		request.setAttribute("rubbishChargeRet", rubbishChargeRet);
		request.setAttribute("lightChargeRet", lightChargeRet);
		request.setAttribute("water2ndChargeRet", water2ndChargeRet);

		return mapping.findForward("doQuery_CompanyMonthlyCharge");
	}
	//执行公司收费月汇总导出Excel表格操作
	public ActionForward companyMonthlyChargeExcel(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		// 获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm) form;
		int year = pqform.getYear();
		int month = pqform.getMonth();

		List<Map<String, Object>> queryList = new ArrayList<Map<String, Object>>();
		// 获得所有的小区
		List<SubDistrict> subList = managementService.findSubDistricts();
		for (SubDistrict sub : subList) {
			queryList.add(propQueryService.querySubMonthlyCharge(sub, year,
					month));

		}
		try{
			response.setContentType("octets/stream"); 
			//设置表名
			String fileName="公司收费月汇总("+year+"年"+month+"月)";
			response.addHeader("Content-Disposition","attachment;filename="+new String(fileName.getBytes("GBK"),"ISO8859-1")+".xls"); 
			
            OutputStream out = response.getOutputStream();
            
            //设置表格中的字段名
            String[] headers = {"小区", "应缴金额", "实收金额","物业服务费","电费","水费","停车服务费","垃圾清运费","路灯电费","二次提水费"};
            //设置Key，然后通过这个Key去Map数组中取值
            String[] columns ={"subName","totalSum","paidSum","propCharge","powerCharge","waterCharge","carCharge","rubbishCharge","lightCharge","water2ndCharge"};
            
            ExportExcelUtils.exportExcel("公司收费月汇总表", headers, columns, queryList, out, "");
            out.close();
		}catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	// 跳转到公司收费年汇总查询条件页面
	public ActionForward queryCompanyYearlyCharge(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		// 获得所有的物业服务处
		List<District> distList = managementService.findDistricts();
		request.setAttribute("distList", distList);

		return mapping.findForward("query_CompanyYearlyCharge");
	}

	// 执行公司收费年汇总查询操作
	public ActionForward doqueryCompanyYearlyCharge(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		// 获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm) form;
		int year = pqform.getYear();
		int month = pqform.getMonth();

		List<Map<String, Object>> queryList = new ArrayList<Map<String, Object>>();
		// 获得所有的小区
		List<SubDistrict> subList = managementService.findSubDistricts();
		for (SubDistrict sub : subList) {
			// 输入月份为-1表示只查询年份
			queryList
					.add(propQueryService.querySubMonthlyCharge(sub, year, -1));
		}
		//统计总数
		float totalSumRet = 0;
		float paidSumRet = 0;
		float propChargeRet = 0;
		float powerChargeRet = 0;
		float waterChargeRet = 0;
		float carChargeRet = 0;
		float rubbishChargeRet = 0;
		float lightChargeRet = 0;
		float water2ndChargeRet = 0;
		for (int i = 0; i < queryList.size(); i++) {
			totalSumRet += Float.parseFloat(queryList.get(i).get("totalSum")
					.toString());
			paidSumRet += Float.parseFloat(queryList.get(i).get("paidSum")
					.toString());
			propChargeRet += Float.parseFloat(queryList.get(i).get("propCharge")
					.toString());
			powerChargeRet += Float.parseFloat(queryList.get(i).get("powerCharge")
					.toString());
			waterChargeRet += Float.parseFloat(queryList.get(i).get("waterCharge")
					.toString());
			carChargeRet += Float.parseFloat(queryList.get(i).get("carCharge")
					.toString());
			rubbishChargeRet += Float.parseFloat(queryList.get(i).get("rubbishCharge")
					.toString());
			lightChargeRet += Float.parseFloat(queryList.get(i).get("lightCharge")
					.toString());
			water2ndChargeRet += Float.parseFloat(queryList.get(i).get("water2ndCharge")
					.toString());
		}
		log.info("queryList.size()=" + queryList.size());
		request.setAttribute("queryList", queryList);
		request.setAttribute("year", year);
		request.setAttribute("totalSumRet", totalSumRet);
		request.setAttribute("paidSumRet", paidSumRet);
		request.setAttribute("propChargeRet", propChargeRet);
		request.setAttribute("powerChargeRet", powerChargeRet);
		request.setAttribute("waterChargeRet", waterChargeRet);
		request.setAttribute("carChargeRet", carChargeRet);
		request.setAttribute("rubbishChargeRet", rubbishChargeRet);
		request.setAttribute("lightChargeRet", lightChargeRet);
		request.setAttribute("water2ndChargeRet", water2ndChargeRet);

		return mapping.findForward("doQuery_CompanyYearlyCharge");
	}
	//执行公司收费年汇总导出Excel表格操作
	public ActionForward companyYearlyChargeExcel(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		// 获得表单数据
		PropQueryActionForm pqform = (PropQueryActionForm) form;
		int year = pqform.getYear();

		List<Map<String, Object>> queryList = new ArrayList<Map<String, Object>>();
		// 获得所有的小区
		List<SubDistrict> subList = managementService.findSubDistricts();
		for (SubDistrict sub : subList) {
			queryList.add(propQueryService.querySubMonthlyCharge(sub, year,
					-1));

		}
		try{
			response.setContentType("octets/stream"); 
			//设置表名
			String fileName="公司收费年汇总("+year+"年)";
			response.addHeader("Content-Disposition","attachment;filename="+new String(fileName.getBytes("GBK"),"ISO8859-1")+".xls"); 
			
            OutputStream out = response.getOutputStream();
            
            //设置表格中的字段名
            String[] headers = {"小区", "应缴金额", "实收金额","物业服务费","电费","水费","停车服务费","垃圾清运费","路灯电费","二次提水费"};
            //设置Key，然后通过这个Key去Map数组中取值
            String[] columns ={"subName","totalSum","paidSum","propCharge","powerCharge","waterCharge","carCharge","rubbishCharge","lightCharge","water2ndCharge"};
            
            ExportExcelUtils.exportExcel("公司收费年汇总表", headers, columns, queryList, out, "");
            out.close();
		}catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
